package com.vegetable.modules.entity.sys;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;


/**
 * 系统日志
 *
 * @author Mark sunlightcs@gmail.com
 */
@Data
@TableName("sys_log")
public class SysLogEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	@ApiModelProperty(value = "主键")
	@TableId(value = "id", type = IdType.ASSIGN_ID)
	@JsonSerialize(using = ToStringSerializer.class)
	private Long id;
	//用户名
	private String username;
	//用户操作
	private String operation;
	//请求方法
	private String method;
	//请求参数
	private String params;
	//执行时长(毫秒)
	private Long time;
	//IP地址
	private String ip;

	private String userAgent;
	//创建时间
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private Date createDate;

	@TableField(exist = false)
	private String result;

	private String md5Check;
	
	// 实体类名
	private String entityClass;
	
	// 实体ID
	private String entityId;
	
	// 修改前的数据
	private String beforeData;
	
	// 修改后的数据
	private String afterData;
	
	// 操作类型 (INSERT, UPDATE, DELETE, SELECT)
	private String operationType;
	
	// 字段变更详情
	@TableField(exist = false)
	private Map<String, Object[]> fieldChanges;
	
	// 详细的字段变更信息（包含字段描述）
	@TableField(exist = false)
	private List<Map<String, Object>> detailedFieldChanges;
}